using System;
using System.Collections.Generic;
using System.Text;

namespace TVDesigner.Generator.Components
{
    public class HButton : HIcon
    {
        private string _SelectedImage;
        private string _HScreenName;
        private string _Text;
        private System.Drawing.Color _Foregroud;

        public System.Drawing.Color Foreground
        {
            get { return _Foregroud; }
            set { _Foregroud = value; }
        }
        public string Text
        {
            get { return _Text; }
            set { _Text = value; }
        }
        public string SelectedImage
        {
            get { return _SelectedImage; }
            set { _SelectedImage = value; }
        }        
        public string HScreenName
        {
            get { return _HScreenName; }
            set { _HScreenName = value; }
        }


        public override string TypeString
        {
            get { return "org.havi.ui.HIcon"; }
        }
	
        protected override void SetAtributes(StringBuilder sb)
        {
            base.SetAtributes(sb);
            if (this.SelectedImage != null && !this.SelectedImage.Equals(string.Empty))
            {
                sb.Append("\t\t\tjava.awt.Image selectedImage = ImagesController.getInstance().getImage(\"").Append(this.SelectedImage).Append("\");\n");
                sb.Append("\t\t\tif (selectedImage != null) {\n");
                sb.Append("\t\t\t\t").Append(NameStartedWithLowerCase).Append(".setGraphicContent(selectedImage, org.havi.ui.HVisible.FOCUSED_STATE);\n");
                sb.Append("\t\t\t}\n");
            }

            if (this.Text != null && !this.Text.Equals(string.Empty))
            {
                sb.Append("\t\t\t").Append(NameStartedWithLowerCase).Append(".setHorizontalAlignment(org.havi.ui.HText.HALIGN_LEFT);\n");
                sb.Append("\t\t\t").Append(NameStartedWithLowerCase).Append(".setVerticalAlignment(org.havi.ui.HText.VALIGN_TOP);\n");

                sb.Append("\t\t\t").Append(NameStartedWithLowerCase).Append(".setTextContent(\"").Append(_Text).Append("\", org.havi.ui.HVisible.ALL_STATES);\n");
                sb.Append("\t\t\tjava.awt.Font font = new java.awt.Font(\"Arial Black\", java.awt.Font.PLAIN, 20);\n");
                sb.Append("\t\t\t").Append(NameStartedWithLowerCase).Append(".setFont(font);\n");

                sb.Append("\t\t\tjava.awt.Color color = new java.awt.Color(").Append(this.Foreground.ToArgb()).Append(");\n");
                sb.Append("\t\t\t").Append(NameStartedWithLowerCase).Append(".setForeground(color);\n");

                sb.Append("\t\t\t//").Append(NameStartedWithLowerCase).Append(".setBackground(org.dvb.ui.DVBColor.TRANSLUCENT);\n");
            }
        }
    }
}
